﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Peak.Web.Controllers.Models
{
  public class DashboardFilterModel
  {
    public bool StatusToDo { get; set; }
    public bool StatusInProgress { get; set; }
    public bool StatusReadyForTest { get; set; }
    public bool StatusDone { get; set; }

    public bool CurrentSprintOnly { get; set; }

    public string AssignedTo{ get; set;}
    public bool Assigned { get; set; }
    public string QuickFilter{ get; set;}
    
    public DashboardFilterModel()
    {
      StatusToDo = StatusReadyForTest = true;      
      CurrentSprintOnly = true;
      Assigned = false;
    }

    public string GetDescription()
    {
      string result = "";
      if (StatusToDo && StatusInProgress && StatusDone && !CurrentSprintOnly)
      {
        result = "All items";
      }
      else
      {
        if (CurrentSprintOnly)
        {
          result = "Items from current sprint in status [";
        }
        else
        {
          result = "items in status [";
        }
        if (StatusToDo)
        {
          result += "To do,";
        }
        if (StatusInProgress)
        {
          result += "in progress,";
        }
        if (StatusReadyForTest)
        {
          result += "ready for test,";
        }
        if (StatusDone)
        {
          result += "done,";
        }
        result = result.Remove(result.Length - 1, 1);
        result += "]";
      }
      if (AssignedTo != null)
      {
        if (AssignedTo == Thread.CurrentPrincipal.Identity.Name)
        {
          result += ", assigned to me";
        }
        else
        {
          result += ", assigned to user [" + AssignedTo + "]";
        }
      }
      return result;
    }
  }
}
